`contingencyTable` <-
function(rule, data)
{
	# contingencyTable
	nr = 0 # number of examples covered by rule
	nc = 0 # number of examples belonging to class
	n_r = 0 # number of examples not covered by rule
	n_c = 0 # number of examples not belonging to class
	nrc = 0 # number of examples belonging to class and covered by rule
	n_rc = 0 # number of examples belonging to class and not covered by rule
	nr_c = 0 # number of examples not belonging to class and covered by rule
	n_r_c = 0 # number of examples not belonging to class and not covered by rule	
	N = nrow(data)
	
	for(i in 1:nrow(data)){
		if(rule.evaluate(rule,data[i,])){
			nr = nr + 1
			if(data[i,"class"] == rule$class){
				nrc = nrc + 1
			} else {
				nr_c = nr_c + 1
			}
		} else {
			if(data[i,"class"] == rule$class){
				n_rc = n_rc + 1
			} else {
				n_r_c = n_r_c + 1
			}
			n_r = n_r +1
		}
		
		if(data[i,"class"] == rule$class){
			nc = nc + 1
		} else {
			n_c = n_c + 1
		}
	}
	return (c("nr"=nr, "n_r"=n_r, "nc"=nc, "n_c"=n_c, "nrc"=nrc, "n_rc"=n_rc, "nr_c"=nr_c, "n_r_c"=n_r_c, "N"=N))
}

